package v2.chapter9.jaas3;

import java.security.Principal;

public class SamplePrincipal implements Principal {
	private String name;
	
	public SamplePrincipal(String name) {
		this.name=name;
	}
	
	public boolean equals(Object o) {
		if(o==null) return false;
		
		if(this==o) return true;
		
		if(!(o instanceof SamplePrincipal)) return false;
		
		SamplePrincipal sample=(SamplePrincipal) o;
		if(this.getName().equals(sample.getName())) return true;
		return false;
	}
	
	public int hashCode() {
		return name.hashCode();
	}

	@Override
	public String getName() { 
		return name;
	} 
}
